package org.luckystrophe.snowtoms;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.actionbarsherlock.app.SherlockActivity;
import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.Click;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_coach)
public class CoachActivity extends SherlockActivity {

	@ViewById(R.id.iv_coach_background)
	ImageView iv_coach;

	@AfterViews
	public void afterViews() {
		Intent i = getIntent();
		int imageNumber = i.getIntExtra("coachImageNumber", 0);
		setCoachBackground(imageNumber);
	}

	@SuppressWarnings("deprecation")
	private void setCoachBackground(int imageNumber) {
		if (imageNumber == 0) {
			finish();
			return;
		}

		Drawable coachBackgroundDrawable = null;
		if (imageNumber == 1) {
			coachBackgroundDrawable = getResources().getDrawable(R.drawable.cm_01);
		} else if (imageNumber == 2) {
			coachBackgroundDrawable = getResources().getDrawable(R.drawable.cm_02);
		} else if (imageNumber == 3) {
			coachBackgroundDrawable = getResources().getDrawable(R.drawable.cm_03);
		}

		iv_coach.setBackgroundDrawable(coachBackgroundDrawable);
	}

	@Click(R.id.iv_coach_background)
	public void clickCoach() {
		finish();
		overridePendingTransition(R.anim.fadein, R.anim.fadeout);
	}

}
